from django.db import models
from deploy.models import deployInfo

class imageInfo(models.Model):
    '''
    镜像信息
    '''
    name = models.CharField(max_length=30,verbose_name="名称")
    application_type = models.CharField(max_length=8,null=False,blank=False,verbose_name='项目类型')
    # application = models.ForeignKey(deployInfo,on_delete=models.CASCADE,null=True,blank=True,verbose_name="关联deployInfo",help_text="关联deployInfo")
    tag = models.CharField(max_length=20,null=False,blank=False,verbose_name="标签")
    test = models.CharField(max_length=200,default="repo.panda-inner.co",null=False,blank=False,verbose_name="test仓库")
    create_time = models.DateTimeField(auto_now_add=True,help_text="生成时间",verbose_name="生成时间")
    update_time = models.DateTimeField(auto_now=True,help_text="tag更新时间",verbose_name="tag更新时间")

    class Meta:
        verbose_name = "镜像信息"
        verbose_name_plural = verbose_name
        db_table = "image_info"
        ordering = ['id']

    def __str__(self):
        return self.name


class push_log(models.Model):

    '''
    推送记录
    '''
    name = models.CharField(max_length=30,null=True,blank=True,verbose_name="名称",help_text="名称")
    application_type = models.CharField(max_length=8,null=True,blank=True,verbose_name='项目类型')
    # image = models.ForeignKey(imageInfo,on_delete=models.CASCADE,null=True,blank=True,verbose_name="关联镜像",help_text="关联镜像")
    tag = models.CharField(max_length=20,null=True,blank=True,verbose_name="标签",help_text="标签")
    push_env = models.CharField(max_length=10,verbose_name="目标目标环境",help_text="推送目标环境")
    push_time = models.DateTimeField(auto_now_add=True, verbose_name="推送日期", help_text="推送日期")
    push_user = models.CharField(max_length=50,null=True,blank=True,verbose_name="用户",help_text="用户")
    status = models.BooleanField(default=True,verbose_name="推送状态",help_text="推送状态")

    class Meta:
        verbose_name = "镜像推送记录"
        verbose_name_plural = verbose_name
        ordering = ['id']
        db_table = "push_log"

    def __str__(self):
        return self.name


